﻿using M.Warehouse.API.Application.Command.InventoryCommand;
using M.Warehouse.Repository.WarehouseInterface;
using MediatR;

namespace M.Warehouse.API.Application.CommandHandlers.InventoryHandlers
{
    public class InventoryUpdStateCommandHandlers : IRequestHandler<InventoryUpdStateCommand, int>
    {
        private readonly IInventoryRepository _inventoryRepository;
        public InventoryUpdStateCommandHandlers(IInventoryRepository inventoryRepository)
        {
            _inventoryRepository = inventoryRepository;
        }
        public async Task<int> Handle(InventoryUpdStateCommand request, CancellationToken cancellationToken)
        {
            var list=await _inventoryRepository.GetModelAsync(request.InventoryId);
            list.InventoryState=!list.InventoryState;
            return await _inventoryRepository.Update(list);
        }
    }
}
